package com.polaris.live.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.polaris.live.R
import com.polaris.live.common.adapter.BaseAdapter
import com.polaris.live.common.ext.dp
import com.polaris.live.databinding.AdapterMeGameBinding
import com.polaris.live.resp.bean.MeGameBean
import com.polaris.live.utils.image.ImageUtils

/**
 * MeGameAdapter 玩法说明adapter
 * @author Created by 天晴 on 2024/1/19 11:30
 * @since 1.0.0
 **/
class MeGameAdapter : BaseAdapter<MeGameBean, MeGameAdapter.MeGameHolder>(0) {


    init {
        addChildClickViewIds(R.id.contect)
    }

    override fun onCreateDefViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): MeGameHolder {
        return MeGameHolder(
            AdapterMeGameBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        )
    }

    override fun convert(holder: MeGameHolder, item: MeGameBean) {
        Glide.with(context)
            .load(ImageUtils.imgPath(item.gameVo.iconRound))
            .transform(CenterCrop(), RoundedCorners(8.dp))
            .into(holder.binding.image)
        if (item.showDot) {
            holder.binding.redDot.visibility = View.VISIBLE
        } else {
            holder.binding.redDot.visibility = View.GONE
        }
    }

    inner class MeGameHolder(val binding: AdapterMeGameBinding) :
        BaseViewHolder(binding.root)
}